package com.qst.crop.dao;

import com.qst.crop.entity.Knowledge;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface KnowledgeDao {
    @Select("select * from tb_knowledge")
    List<Knowledge> findAll();

    @Select("select * from tb_knowledge where knowledge_id=#{id}")
    Knowledge findById(Integer id);

    @Insert("insert into tb_knowledge(title, content, pic_path, own_name, create_time, update_time) " +
            "VALUES(#{title},#{content},#{picPath},#{ownName},#{createTime},#{updateTime}) ")
    void insert(Knowledge knowledge);

    void update(Knowledge knowledge);

    @Delete("delete from tb_knowledge where knowledge_id=#{id}")
    void deleteById(Integer id);



    List<Knowledge> findByCondition(String condition);

    @Select("select * from tb_knowledge where own_name=#{currentUserName}")
    List<Knowledge> getByUserName(String currentUserName);


}
